package com.myzhouye.business.generator;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.generator.AutoGenerator;
import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.*;
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;

import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class mpGeneratorNew {
    public static void main(String[] args) {
        String url="jdbc:mysql://10.193.11.6:3306/maple_sse_demo?useUnicode=true&useSSL=false&characterEncoding=utf8&serverTimezone=Asia/Shanghai";
        String username="talent";
        String password="Talent_2023";
        String moduleName="maple-sse-demo";


        generator(url, username, password,moduleName);
    }

    private static void generator(String url, String username, String password,String moduleName) {


        FastAutoGenerator.create(url, username, password)
                .globalConfig(builder -> {
                    String str2=System.getProperty("user.dir").replace("maple-main",moduleName);
                    str2+=File.separator+"src/main/java/";
                    builder.author("maple") // 设置作者
                            .enableSwagger() // 开启 swagger 模式
                            .fileOverride() // 覆盖已生成文件
                            .outputDir(str2); // 指定输出目录
                })
                .packageConfig(builder -> {
                    String str1=System.getProperty("user.dir").replace("maple-main",moduleName);
                    str1+=File.separator+"src/main/resources/mapper/";
                    builder.parent("com.myzhouye.business") // 设置父包名
                            .pathInfo(Collections.singletonMap(OutputFile.mapperXml, str1)); // 设置mapperXml生成路径
                })
                .strategyConfig(builder -> {
                    builder.addInclude("aaa");
                })
                .execute();
    }
}
